import java.io.*;

public class OutputStreamWriterDemo {
    public static void main(String[] args) {
        try (
                //定义一个字节输出流
                OutputStream os = new FileOutputStream("file-io\\src\\data6.txt");
                //转换成自定义编码的字符输出流
                Writer osw = new OutputStreamWriter(os, "GBK");
                //包装成缓冲输出流
                BufferedWriter bw = new BufferedWriter(osw);
        ) {
            bw.write("这是第一行");
            bw.newLine();
            bw.write("这是第二行");
            bw.newLine();
            bw.write("这是第三行");
            bw.newLine();
            bw.write("这是第四行");
            bw.newLine();
            bw.write("这是第五行");
            bw.newLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
